解决方案 »

  1.   

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

  2.   

    你上面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>
      

  3.   

    直接在你拼接的那串html里面加href就是了。因为a标签有点特殊用href就可以了不用onclick
    "<tr height=\"22\"><td colspan=\"2\"><a style=\"cursor:pointer\"><a title='" 
             + item.title + "' href=\"javascript:xxx();\">[" + item.fType +"]"+ title +"</a></td><td width=\"120\" colspan=\"2\" style='color:#888'>" + item.createTime + "<td>"
    function xxx(){....}
      

  4.   

    刚刚写了个,给个样版你看看 $(function() {
    var ers = null;
    $("#searchbtn").click( function() {
    $("#nodelist").html(""); var searchText = $("#searchtext").val();
    var url = $("#path").val() + "/map_search.do";
    $.post(url, {
    "name" : searchText
    }, function(data) {
    if (data.items == "") {
    $("#nodelist").html("没有匹配的数据").css("color", "red");
    return;
    }
    $("#nodelist").css("color", "blue").append(
    "<table id='nodetable'><thead><tr><th>gid</th>"
    + "<th>name</th>" + "<th>kind</th>"
    + "<th>geom</th>" + "<th>经度</th>"
    + "<th>纬度</th>"
    + "</tr></thead></table>");
    var table = $("#nodetable"); if (ers != null) {
    map.removeLayer(ers);
    }
    ers = new OpenLayers.Layer.Markers("Markers");
    map.addLayer(ers);
    $.each(data.items, function(i, v) {
    var gid = v.gid == null ? "" : v.gid;
    var name = v.name == null ? "" : v.name;
    var kind = v.kind == null ? "" : v.kind;
    var geom = v.geom == null ? "" : v.geom;
    var lon = v.lon == null ? "" : v.lon;
    var lat = v.lat == null ? "" : v.lat;
    table.append("<tr><td>" + gid + "</td>" + "<td><a href='javascript:moveLonLat("+lon
    +","+lat+")'>"
    + name + "</a></td>" + "<td>" + kind + "</td>"
    + "<td>" + geom + "</td>" + "<td>" + lon
    + "</td>" + "<td>" + lat + "</td>"
    + "</tr>");
    //POINT(114.03758592 22.57226001)
    /*  var point = geom.replaceAll("POINT|\\(|\\)","");
    var strPoint = point. */

    var size = new OpenLayers.Size(21, 25);
    var offset = new OpenLayers.Pixel(-(size.w / 2),
    -size.h);
    var icon = new OpenLayers.Icon(
    'openlayers/img/er.png', size, offset);
    ers.addMarker(new OpenLayers.Marker(
    new OpenLayers.LonLat(lon, lat), icon));

    if(i==0){
    moveLonLat(lon, lat);
    }
    });
    });
    });

    });
    function moveLonLat(lon, lat) {
    map.panTo(new OpenLayers.LonLat(lon, lat));
    map.zoomTo(6);
    }