I have the following where if you click on one of the list items, a JavaScript function will be called. This should run the jQuery below to hide/show an element.
div#user-box
ul
li#dashboard(href="javascript:showonlyone('newboxes1')")
a Dashboard
li#settings(href="javascript:showonlyone('newboxes2')")
a Settings
div(class='newboxes' id='newboxes1')
p Dashboard
div(class='newboxes' id='newboxes2')
p Account ID:
I tried this and but it didn't work:
$(document).ready(function() {
var showonlyone = function(thechosenone) {
$('.newboxes').each(function(index) {
if ($(this).attr("id") == thechosenone) {
$(this).show(200)}
else {
$(this).hide(600);
}
})
}
})
The functionality must be working, it's just that the function must not be called when clicking on the list items.