これは83Kbのファイル(JSのみ)ですが、これは恐ろしいことではありませんが、あなたがしようとしているものにはかなり大きなものです。あなたがしたいすべてがctrl+shift
が開催されたダウンしている場合tr
要素をクリックすると、あなたは、コードの83キロバイトよりもはるかに少ない使用することができますしながら、テストがある場合
//select the parent table element, then select its child (the `tbody` element) then get its children which will be the `tr` elements
$('table').children().children().on('click', function (event) {
//check to see if ctrl+shift is being held while this click occured
if (event.ctrlKey === true && event.shiftKey === true) {
//if ctrl+shift were held during the click then you know this element has been selected
//and you can do what you need, in this demo I'm just adding a class to denote that the element has been selected
$(this).toggleClass('selected');
}
});
あなたが見ることができるように、(上記のデモは600のバイトです)。ここで
はデモです:.on()
はjQueryの1.7であり、この場合には新しいものであることをhttp://jsfiddle.net/YZytJ/
注.bind()
を使用するのと同じです:http://api.jquery.com/on
「選択された」表の行要素ではどうしますか? – Jasper