开发者

Jquery click function only works on one instance of a Button

开发者 https://www.devze.com 2023-01-18 17:17 出处:网络
I\'m using the same button twice on one page,but this click function is only working for one of them:

I'm using the same button twice on one page, but this click function is only working for one of them:

<script type="text/javascript">
    $('#back_button').click(function(){
        window.location.replace('__mem_url__');
    }开发者_如何学Go);
</script>

Here's the button:

<input type="submit" id="back_button" value="Back to Memberships" name="adm_mlevels_update" class="form_input_submit">


The id of a DOM element should be unique. You are using an id selector $('#back_button') so this will apply to only a single button as there could be only a single element in your document with id="back_button". You could use a class selector instead:

$('.form_input_submit').click(function(){
    window.location.replace('__mem_url__');
});
0

精彩评论

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