0

Hi I am trying to change the type of <input> from submit to image using jquery so that the image is displayed during the AJAX request instead of the button. I am doing:

    $(document).ajaxStart(function(){$("#submit_btn").removeAttr("type").attr("image");});  

and my HTML is:

<input type="submit" name="submit" class="button" id="submit_btn" value="Send" src="images/sending.gif" />

Am I doing it the right away? And if so, what's wrong because this ain't working :p

1
  • I solved it by using .hide() and .show() so: $(document).ajaxStart(function(){$("#submit_btn").hide(); $("#sending").show(); }); Now on .ajaxStart event the button hides and the image shows- with proper CSS positioning it gives the illusion of being replaced with an image. So it works- but not sure if it's the best way! Commented Apr 10, 2011 at 0:46

2 Answers 2

2

I think you're looking for:

$(document).ajaxStart(function(){$("#submit_btn").attr("type","image");});

Using attr() to set the attribute, rather than removing it.

Sign up to request clarification or add additional context in comments.

Comments

0

May be this work for you:

$(document).ajaxStart(function(){$("#submit_btn")..attr(type : 'image');}); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.