I try to toggle some elements(labels/fields/img) with jQuery based on the jQuery ends with selector. Everything works fine in IE/Firefox/Safari - but not on Google's Chrome. There's an issue with img elements on the document.ready() function. Chrome does not toggle those img elements.
Any Idea, suggestions? Thank you.
jQuery 1.5.1 Chrome 12.0.742.100
<script type="text/javascript">
$(document).ready(functio开发者_开发技巧n () {
var v = $('#VNType').val();
if (v == 'equalToVP') {
ToggleVisibility();
}
});
function ToggleVisibility() {
//jquery ends with selector
//hide label/fields/img
$('[id$="VN"]').toggle();
$('[for$="VN"]').toggle();
}
It is probably due to the fact that ready
fires prior to images being loaded. Try load
instead and see if it fixes the issue.
$(window).load(function () {
// run code
});
精彩评论