Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with getting correct href attribute from link

Posted on 2013-01-06
2
Medium Priority
?
354 Views
Last Modified: 2013-01-06
Hi,

I have several delete buttons on my page. I want the user to first confirm before the item is really deleted.

i use the code below, be it isn't working correctly. All the delete buttons have the "alert"-class. But after clicking delete, the item with the first delete class is always deleted.
How to make this code direct to the url of the delete button that is clicked?

Changing  "$(".alert").attr("href");" to "$(this).attr("href");" didn't work

	$(".alert").click(function(e) {
 		e.preventDefault();		
		$("#alert").dialog({
		  autoOpen:false, modal:true, draggable:false, width: 312,
		  buttons : {
			"Ja" : function() {
			  window.location.href = $(".alert").attr("href");
			},
			"Nee" : function() {
			  $(this).dialog("close");
			}
		  }
		});
		$("#alert").dialog("open");
	});	  	

Open in new window


Thanks!
0
Comment
Question by:peps03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 38749201
$(".alert").click(function(e) {
             e.preventDefault();
$(".mark").removeClass("mark");
$(this).addClass("mark");      

            $("#alert").dialog({
              autoOpen:false, modal:true, draggable:false, width: 312,
              buttons : {
                  "Ja" : function() {
                    window.location.href = $(".mark").attr("href");
                  },
                  "Nee" : function() {
                    $(this).dialog("close");
                  }
              }
            });
            $("#alert").dialog("open");
      });
0
 

Author Closing Comment

by:peps03
ID: 38749225
Thanks a lot!!!
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question