我需要在选择图像时更新对话框的标题。我在 chrome 中调试,Inspect Element
我对这个值的观察在下面的评论中给出:
function setDialogTitle(item){ // item is input#searchclassimg.imagewrapper
var id = item.id; // gives id of selected element
switch(id){
// dialog is a div, whose default title is "Some picker"
case "searchclassimg":
$('#dialog').attr('title', 'Class Picker'); //after this i expect dialog's title to be updated as "Class Picker"
break;
case "searchsectionimg":
$('#dialog').attr('title', 'Section Picker');
break;
case "searchrollnoimg":
$('#dialog').attr('title', 'Roll No Picker');
break;
case "searchnameimg":
$('#dialog').attr('title', 'Name Picker');
break;
}
}
$(document).ready( function() {
if (!window.jQuery) {
document
.write('<link rel="stylesheet" href="/WEB-INF/lib/jquery-ui-themes-1.10.3/themes/smoothness/jquery-ui.css"><\/link>');
document
.write('<script src="/WEB-INF/lib/jquery-1.10.1.js"><\/script>');
document
.write('<script src="/WEB-INF/lib/jquery-ui.js"> <\/script>');
}
var counter = 0;
$(".imagewrapper").click(function() {
$("#dialog").dialog();
setDialogTitle(this);
if (counter < 1) {
$("#searchboxdiv").after('<hr id="separator1">');
$("#separator1").after('<div id="contents" class="container"> </div>');
setDialogItems();
counter++;
}
});
$(document).on('click', "#searchbutton", function() {
var data1 = $("#searchbox").val();
$.ajax({
url : "FormHandler",
data : {
data1 : data1
},
success : function(result) {
var result = null;
}
});
});
ImageWrapper<div>
在其下定义了多个元素。执行后我得到的只是“一些选择器”。我在哪里犯错请指出。