开发者

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 sr开发者_如何学运维c needs to be absolute.

Any help cheers


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...'


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜