I'm facing a problem in using the HTML code contained in a javascript variable with the DOM methods like getElementsByTagName("img"), .removeAttribute("alt"), etc. I want to remove the alt attribute from all the <img>
tags present within the HTML code and having alt attribute. Following are few lines of my code:
$(".show_sub_questions").click(function() {
var sub_id = $(this).attr('id');
$('#'+sub_id).removeClass("show_sub_questions");
var subject_name = $('#'+sub_id).attr('class');
$('#'+sub_id).addClass("show_sub_questions");
**var data = $('#popup_'+sub_id).html();**
var title = "Test Result";
var dialog_title = title;
var subject_name = "<div class='s_name'><b>Subject Name : </b>"+subject_name+"</div><br />";
var dialog_message = subject_name+data;
var $dialog = $("<div class='view_result'></div>")
.html(dialog_message)
.dialog({
autoOpen: false,
modal:true,
title: dialog_title,
width: 900,
close:{
}
});
$dialog.dialog('open');
return false;
});
I'm getting the HTML code from the .tpl file which is added to the popup. Please help me out from this issue of accessing html code with DOM methods. The step written within ** and ** is the HTML code giving step. I want to use DOM methods on the same HTML code.