0

So a project has been passed to me and there is a button on a Twitter bootstrap sidebar doing a search dynamically. I cannot figure out which calls the button is making, and I need to replicate its functionality with another button. (We want two buttons doing the same thing) is there a way to use jquery (find maybe?) to do this? I was trying something like this:

$side-bar.find('#newSearchButton').on('click', function(){
    $side-bar.find('#oldSearchButton')._data.events.click[0].handler;
});

I know this is wrong, but I don't know what to do to make it work. I just want to be able to make the new search button perform the same search as the old search button.

4

2 回答 2

1

难道你不能使用一个功能,当点击新按钮时,点击旧按钮,从而在旧按钮背后发挥作用。

$('#newSearchButton').click(function(){
    $('#oldSearchButton').click();
});
于 2013-10-10T16:21:21.310 回答
0

您可以为对象列表设置相同的回调。在您的情况下,您可以执行以下操作:

$side-bar.find('.MyButton').on('click', function(){
    // do something
});

请注意,您必须在按钮标签中包含 class="MyButton" 才能使其正常工作。

于 2013-10-10T16:20:48.697 回答