Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Find Matching Content JQuery


rwilson - 2:04 pm on Feb 21, 2012 (gmt 0)


Thanks that helps point me in the right direction but, when I try to use a variable it doesn't work. Can this be done? Am I just overlooking something? Thanks again!

<script type="text/javascript">
$(document).ready(function () {
var h1_text = $('h1').text();
$("#sideMenu a:contains('h1_text')").addClass("selectedListItem");

/* Using exact text works
$("#sideMenu a:contains('My Page Name')").addClass("selectedListItem");
*/
});

</script>

<style type="text/css">
.selectedListItem{font-weight:bold;}
</style>

</head>

<body>

<h1>My Page Name</h1>

<ul id="sideMenu">
<li><a href="#">sample 1</a></li>
<li><a href="#">sample 2</a></li>
<li><a href="#">sample 3</a></li>
<li><a href="#">My Page Name</a></li>
<li><a href="#">sample 5</a></li>
</ul>


Thread source:: http://www.webmasterworld.com/javascript/4418963.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com