xml parsing - Jquery object innerHTML working in Firefox but not IE? -
in summary have xml string use jquery find children of specific node.
these children , values used build html select box , append webpage.
the xml
<!--- node level !--> <salutation restricted="no" type="dropdownbox" tooltip="select title customer" required="yes" size="6"> <value>mr</value> <value>sir</value> <value>mrs</value> <value>miss</value> <value>lord</value> </salutation> the code
function dropdownbuilder( xml, element, id ) { // find node specific name , children selection = $("<div>" + xml + "</div>").find(element).children(); console.log( selection ); // generate select box var selectbox = "<select id=\"" + id + "\"> "; ( var j = 0; j < selection.length; j++ ) { selectbox += "<option value=\"" + selection[j].innerhtml + "\">" + selection[j].innerhtml + "</option>"; } selectbox += "</select>"; // return html return selectbox; } output firefox
<select id="dropdownbox1" data-hasqtip="true" aria-describedby="qtip-1"> <option value="mr">mr</option> <option value="sir">sir</option> <option value="mrs">mrs</option> <option value="miss">miss</option> <option value="lord">lord</option> </select> output ie
<select id="dropdownbox1" data-hasqtip="true" jquery16309410884371447445="60"/> in console log in ie says "log: [object object] "
i have tried changing output using .val() , .value , .data , .attr
any idea why works fine in ff not in ie?
jsfiddle
thanks
you can replace loop in code , should work :
selection.each(function(index) { var text = $(this).text(); selectbox += "<option value=\"" + text + "\">" + text + "</option>"; });
Comments
Post a Comment