Reputation: 317
I'm using a button within a dropdown to redirect when the button is clicked. The button also has an id="" attribute containing an ID which I want to post to the redirected page. To do this, I have used jQuery.redirect from github.
When I click the button nothing happens, I'm using firebug and no errors are present in the console. Where have I gone wrong?
Here is the script
<script type="text/javascript">
$( document ).ready(function() {
$(".triangle input[name='tedit']").click(function(){
var subID = $(this).attr('id');
$.redirect("/profile/subscriptionedit.php",{ subscription: "subID="+ subID, });
});
});
</script>
And the Div's containing the button to be pressed (The button to be pressed is name="tedit")
<div class="dropdownContain">
<div class="triangle"></div>
<ul>
<li><button>Invoices</button></li>
<li><button name="tedit" id="'.$id.'">Edit</button></li>
<li><button id="'.$id.'">Cancel</button></li>
</ul>
</div>
The above is in a PHP foreach echo, which is why $id is displayed as "'.$id.'"
Thanks for your time
Upvotes: 0
Views: 252
Reputation: 317
Changed
$("#triangle input[name='tedit']").click(function(){
to
$(".tedit").click(function(){
and added
class="tedit"
to the button which I wanted to perform the action.
Upvotes: 0
Reputation: 26784
$("#triangle input[name='tedit']").click(function(){
You have an id onclick
But your HTML has a class,change it to an id
<div id="triangle"></div>
Upvotes: 1