クリックしたときにjs/jqueryを実行するには、tr要素内に「いいね」ボタンが必要です。
不思議なことに、インラインのhtml/imageボタンからjquery/jsを実行する方法についての十分な知識を見つけるのに苦労しています。
これが私が念頭に置いていたものです:
まず、いいねボタンのカスタム関数を作成します
jQuery.fn.likebutn = function(theword, wordnumber) {
//check if button is lighted up and if it is break
//change button to lighted up
jQuery(this).attr("src", "http://i46.tinypic.com/n18g3q.png");
//add word to a div element
jQuery('#cntrldiv0').append("<p>theword<p>");
//ajax like.php file with the word and username/id
jQuery.post('like.php', {theword:theword, userid: userid});
};
次に、関数呼び出しとそのパラメーター(テーブルがphpで作成されているため)を画像ボタン要素に動的に挿入します(htmlではインライン)
likebutn({theword: ${'row' . $wordnumber}, wordnumber:$wordnumber});
どの出力
likebutn(theword:forainated、wordnumber:1)
例えば。
では、どうすればそのような関数をhtmlから呼び出すことができますか?
ちなみに、(私が提案しているのではなく)Webサーフィン中に表示されるjquery / js画像ボタンでリッスンするイベントが非常に多いのはなぜですか?htmlでインラインを呼び出すよりも遅いのではないでしょうか?
構成は次のようになります。http://jsfiddle.net/Bc64R/