Specify a function to execute when the DOM is fully loaded.
$(document).ready(function () { $("p").text("The DOM is now loaded and can be manipulated."); });
--为button添加/删除disabled属性
$('#btnCancel').attr('disabled','true');
$('#btnCancel').removeAttr('disabled');
Img
<img id="my_image" src="first.jpg"/>
Then you can change the src in jQuery by:
$("#my_image").attr("src","second.jpg");
To attach this to an onclick event, you could write:
$("#my_image").bind("click", function() { $("#my_image").attr("src","second.jpg"); });
To rotate the image, you could do this:
$("img").bind("click", function() { var src = ($(this).attr("src") === "img1_on.jpg") ? "img2_on.jpg" : "img1_on.jpg"; $(this).attr("src", src);
servlet会缓存img的URL,当请求的url不变时,servlet会把缓存的url对应的图片传回来,所以图片没有被正确设置。可以每次请求时可以在url上多加上当期时期,这个每次请求的url就不同了
$('#imgCaptcha').attr( { src: '<workdesk:jspURL source="/process/SYSTEM/Captcha"/>?time='+now.getTime(), title: "Captcha", alt: "Click me" } );
$("#id").css('display','none'); $("#id").css('display','block'); //or $("#id")[0].style.display = 'none';
$("#id").show(); //display:block $("#id").hide(); //display:none $("#id").toggle(); //切换元素的可见状态:如果元素可见,切换为隐藏;如果元素隐藏,切换为可见