日期:2014-05-18  浏览次数:20766 次

jqery js
   $.each(data.root, function(i, item) {
         var title = "";
         if(item.title.length > 10)
         title = item.title.substring(0,10);
         else 
         title = item.title;
        
         $("#taskData").append("<tr height=\"22\"><td colspan=\"2\"><a style=\"cursor:pointer\"><a title='" 
         + item.title + "'>[" + item.fType +"]"+ title +"</a></td><td width=\"120\" colspan=\"2\" style='color:#888'>" + item.createTime + "<td>")
        });
       怎么给title一个点击事件
js

------解决方案--------------------
后面跟着加click就可以。例如<a click='abc()' title='" 
          + item.title + "'>[" + item.fType +"]"+ title +"</a>
function abc(){

}
------解决方案--------------------
你上面a 标签多写一个吧。
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function() {
var o = [];
o.push("1");
o.push("2");
o.push("3");
$.each(o,
function(i, item) {

$("#taskData").append("<tr height=\"22\"><td colspan=\"2\"><a 

style=\"cursor:pointer\" title='" + item.title + "'>[" + item + "]" + item + "</a></td><td width=\"120\" colspan=\"2\" 

style='color:#888'>"

+ item + "<td>")
});
$("a").bind("click",
function() {
alert($(this).html());
});
});
</script>
</head>
<body>
<table id="taskData">
</table>

</body>

</html>

------解决方案--------------------
直接在你拼接的那串html里面加href就是了。因为a标签有点特殊用href就可以了不用onclick
"<tr height=\"22\"><td colspan=\"2\"><a style=\"cursor:pointer\"><a title='"