I manipulated some html to display a little form in a modal bootstrap like this :
$.each(response, function(i, item){
detail += "<div><input name='detail-tipe' type='checkbox' value='" + response[i].nama_detail + "' class='detail-tipe' /> " + response[i].nama_detail.toString() + "</div>";
});
detail += "$('.detail-tipe').each(function(){
var attrib = $(this).attr('value');
for ( var j=0, k = remo.length; j < k; j++ ) {
if(attrib == remo[j]){
$(this).attr('checked', 'checked');
};
}
})";
But, dollar sign is unterminated. Is it possible Please, advise.
If you want to assign a multi-line string to a variable, you need to put a \\
at the end of each line to tell the interpreter that the string is continuing. Otherwise it thinks you want to start a new line of actual code.
detail += "$('.detail-tipe').each(function(){ \
var attrib = $(this).attr('value'); \
for ( var j=0, k = remo.length; j < k; j++ ) { \
if(attrib == remo[j]){ \
$(this).attr('checked', 'checked'); \
}; \
} \
})";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.