422
422

Reputation: 5770

Add Image onClick

Perhaps not the best title, but here is the issue.

We are creating a submit button, that changes state when user clicks to processing. But wanted to spice it up with a loader image.

So working code is:

<a href='#' class='red' onClick="$(this).update('Processing...'); return false;" style="border:0"><img src='img/check.png' style='vertical-align: middle' /> Finish and Pay</a>

What I am after is:

<a href='#' class='red' onClick="$(this).update('<img src='/img/loader.gif'>Processing...'); return false;" style="border:0"><img src='img/check.png' style='vertical-align: middle' /> Finish and Pay</a>

But it isnt complying, I know it must be a bad declaration, just not sure what I am doing wrong. Or if indeed img src needs to be absolute.

Any help cheers

Upvotes: 0

Views: 726

Answers (2)

cwallenpoole
cwallenpoole

Reputation: 82028

These quotes are not properly escaped:

'<img src='/img/loader.gif'>Processing...'

Also, you may want to assign this click function elsewhere (I don't like creating tags inside an attribute, that can be confusing), and I would definitely close that tag.

This might work better:

'<img src=\'/img/loader.gif\' />Processing...'

Upvotes: 1

Rasika
Rasika

Reputation: 1998

How about using an image button to begin with and changing the src of that?

Upvotes: 0

Related Questions