I have this code below where the problem is that it displays the <span> tag “Open Grid” twice when it should only display it once:
$('.gridTxt', context).each( function() {
var $this = $(this);
var $optionsText = $("<div>Option Type:</div><input type='text' class='gridTxtRow maxRow' readonly='readonly' />")
.attr('name',$this.attr('name')+"[]")
.attr('value',$this.val())
.appendTo( $options )
.after("<span href='#' class='showGrid'>[Open Grid]</span>");
$questionType = $this.val();
});
Now if I remove the <div> tags around the string “Option Type” then it displays the “Open Grid” link once but then the string “Option Type” isn’t displayed.
So how can I display “Option Type:” but making sure it displays “Open Grid” link only once?
Here is the Jsfiddle. Just click on the “Add Question” button and you will see what is happening
Is this what you’re looking for?
http://jsfiddle.net/hnbsV/3/