views:

24

answers:

2

Can anyone help me please, I feel like I am so close. I need to get the value from the “A” tag selected, so I can use it later on down the page. How would you get the partial value of a selected link from links in an array? I am using an accordion. I actually don't think that makes a difference but there might be something useful that accordion has for me to use.

$('#accordion').accordion().bind( 'accordionchange', function(event,ui) {
var $this = $(this),
myTitle = $(this).find('h3 > a.title').text(),
target = $(event.target);

/* = debug code === */
console.log(['myTitle =', myTitle, 'target =', target]);
}

myTitle brings back all values in the array when I really just want it to bring back one and if I create an action in this it just applies it to the last element in the array when I want to apply it to the “a:selected” if that exists.

Any help would be appreciated. Thanks

A: 

First of all, you have some syntax errors in your code, ending the lines with "," instead of ";". Copy paste errors?

Do you have the html code as well? Either way, jQuery closest() could be useful to look at: http://api.jquery.com/closest/

Oscar
A: 

I am sure I was just working on it for too long or something that day because I got it later that day. Thank you for the closest() comment though. I researched it and learned a little about that. But what I was actually trying to figure out had to do with the ui.whatever in the accordion. Here is the code:

var hd = $("#hidden-div");
$(hd).hide();
$("#accordion").accordion().bind( "accordionchangestart", function(event,ui) {
    var content = $(ui.content).find("#oldContent").empty();    
    var myDiv = $(ui.content).find(".container");
    // -- THE SWAP -— 
    $(hd).appendTo(myDiv);
    $(hd).show();
});

Thanks for the help.

brian