Jquery Text Variable
I am trying to get jquery to pick up va开发者_高级运维riable that I am defining and I'm having issues doing it.
$.ajax({
url: "sitemap.php",
cache: false,
success: function(html){
$("#results").append(html);
var $seriestitle = $("#define-title").text();
$('#results a:contains("$seriestitle")').addClass('current-series');
$('a:not(".current-series")').hide();
}
});
This is the code I am using. You can view the page at the following URL:
http://benjammindesigns.com/XML/details/1231.html
There is a span on the page, with the ID 'define-title', that contains text. I am trying to pull the text from that span and use it as my variable.
Any info is greatly appreciated.
you want this:
var $seriestitle = $("#define-title").text();
$('#results a:contains("'+$seriestitle+'")').addClass('current-series');
$('#results a:contains("'+$seriestitle+'")').addClass('current-series');
The span
you're trying to use is in the head
of your document. Move it to the body
.
精彩评论