简体   繁体   中英

Jquery remove attribute not working in IE

I have the following input field:

<input type="image" name="Submit" src="Images/FormButtons/SubmitButton.gif" />

I want to remove the src attribute so i'm using the following function.

  <script>

   jQuery(document).ready(function(){
      $("input[type=image]").removeAttr("src");
    });

  </script>

It works in firefox but doesnt work in IE? Any one know how to get it to work in IE?

Note: Removing an inline onclick event handler using .removeAttr() doesn't achieve the desired effect in Internet Explorer 6, 7, or 8. To avoid potential problems, use .prop() instead:

$element.prop(
> "onclick", null ); console.log( "onclick property: ", $element[ 0
> ].onclick );

src: https://api.jquery.com/removeAttr/

I believe Your Image type will need parenthesis

jQuery(document).ready(function(){
  $("input[type='image']").removeAttr("src");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM