如果您在页面上有一个单词要捕获onclick事件并从中发送ajax请求,那么该怎么做?
答案 0 :(得分:2)
jQuery让这很容易!
<div>Here's the <span class="myLink">word</span></div>
$(document).ready(function() {
/*onclick event*/
$(".myLink").click(function() {
/* The AJAX call*/
$.post('http://myurl.com/',{ 'my' : 'data'},function(response) {
//do something with the result
});
});
});