I am using a jQuery function to add/remove a class to the clicked element, which works just fine. However when that element is clicked, I am trying to change the text of an HTML link and I cannot seem to get it working. The HTML link is located within the <span>
element further down the page.
When <button id=people>
hasClass('user_view_active') the HTML link should display People when <button id=jobs>
hasClass('user_view_active') the HTML link should display Jobs.
<script type=text/javascript>
$(document).ready(function() {
$('button').click(function(){
$('button').each(function(){
$(this).removeClass('user_view_active');
});
$(this).addClass('user_view_active');
});
if ($('#people').hasClass('user_view_active')){
$('.title').find(a).attr(href).text(text.replace('People'));
}else{
$('.title').find(a).attr(href).text(text.replace('Jobs'));
}
});
</script>
</head>
<body>
<div id=container>
<header>
<img src=images/header-name.png width=200px style=display: inline; margin-bottom: -10px;/>
<button id=jobs class=user_view><a href=#>Jobs</a></button>
<button id=people class=user_view_active user_view><a href=#>People</a></button>
<div class=header_search_wrapper>
<form action= method=POST>
<textarea class=header_search name=app_search placeholder=Search people, jobs, or companies style=width: 430px;></textarea>
<input type=submit class=share_btn value=Search>
</form>
</div>
</header>
<div id=main role=main>
<!--! begin app content -->
<div class=right_sidebar>
<span class=right_title>Connection Suggestions</title>
</div>
<span class=title>Recent Updates >> <a href=#>People</a></span>