私はjqueryが初めてです。画像ボタンのセットを生成したかったので、このようにしました
<script type="text/javascript">
$(document).ready(function(){
$.support.cors = true;
if ($('#ulTask li').length == 0)
{
$.ajax({
type: "POST",
url: "http://diana/TaskManagerWebService/TaskManagerService.asmx/SelectAllTasks",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
function OnSuccess(TaskData){
var TaskDataObj = jQuery.parseJSON(TaskData.d);
$.each(TaskDataObj, function (i, v) {
var TaskTypeUrl = getTaskTypeImageURL(TaskDataObj[i].TaskType), TaskId = parseInt(TaskDataObj[i].TaskId);
$("#ulTask").append('<li id="liTask'+TaskDataObj[i].TaskId+'"><div id="divTask'+TaskDataObj[i].TaskId+'"><img id="imgCollapse'+TaskDataObj[i].TaskId+'" alt="' + TaskDataObj[i].TaskId + '" src="Images/story_collapsed1.png" onclick="javascript:FillTaskDetails('+TaskDataObj[i].TaskId+');"/>' + TaskDataObj[i].TaskName + '</div></li>');
});
}
function OnError(request, status, error){
alert(request.statusText);
}
}
});
</script>
for the image which i binded in li tag have onclick event.
onclick="javascript:FillTaskDetails('+TaskDataObj[i].TaskId+');"
I wanted to assign that click event in query formate like
$("#imageId").click(function(){
});
how to i get this "imageId", Actually this imageid is combination of text and dynamic value
<img id="imgCollapse'+TaskDataObj[i].TaskId+'".......
前もって感謝します