Hello,
I'm doing a checkbox that creates / removes anchor tags in a div. And of course those anchor tags serve as navigation, so primarily it should have an onclick event after it is made. By default one item is already checked. All I wanted is that I select all navigation menus through the checkbox. And when I click on those menus it should alert something specific for that specific menu. So my code goes like this
- function displayMenus() {
-
- $("#modal-form input:checkbox").each(function(){
- var v = $(this).val();
- if($(this).is(':checked')&&$('#'+v+'Menu').length === 0){
- var anchorName = "<a href='#' id="+v+"Link class='navPreviewButtons'>"+$(this).val()+"</a>";
- $('#navPreview').append('<div id="'+v+'Menu">');
- $('#'+v+'Menu').append(anchorName);
- }
- if($(this).is(':checked')&&$('#'+v+'Menu').length === 1){
- return true;
- }
- else{
- $('#'+v+'Menu').remove();
- }
- });
- }
- displayMenus();
- $("#modal-form input:checkbox").click(displayMenus);
-
- $('#navPreview a').click(function(){
- alert($(this).text()); });
Any ideas what I've done wrong. Thanks in advance:)