开发者

Simulate a onChange() event with a .val(x) assignment

开发者 https://www.devze.com 2023-01-15 16:19 出处:网络
I have an action on a page whereby a user clicks to remove a div. What I\'d like to achieve is, when the click occurs, automatically change a drop down to show a value and refresh a separate div conte

I have an action on a page whereby a user clicks to remove a div. What I'd like to achieve is, when the click occurs, automatically change a drop down to show a value and refresh a separate div content.

For example:-

$("a.removeTier").live('click', function() {
    //var tier = $(this).attr('id').match(/\d+$/);
    var tier = $(this).parent().parent()开发者_如何学编程.attr('id').match(/\d+$/);
    //Set the drop down to the correct option value. On this action I'd like to mimic a       onChange so the content of another div changes
    $('#tiers').val(tier);
    //Remove the parent div of the link clicked
    $('#tier'+tier).remove();                   
});


Call the change method.

$("a.removeTier").live('click', function() {
    //var tier = $(this).attr('id').match(/\d+$/);
    var tier = $(this).parent().parent().attr('id').match(/\d+$/);
    //Set the drop down to the correct option value. On this action I'd like to mimic a onChange so the content of another div changes
    $('#tiers').val(tier);
    $('#tiers').change();
    //Remove the parent div of the link clicked
    $('#tier'+tier).remove();                   
});
0

精彩评论

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

关注公众号