Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11677 closed bug (invalid)

$(replacingHtml).find("[data-replaced='true']").length is 0. but it is exist.

Reported by: thulasiram.eee@… Owned by:
Priority: low Milestone: None
Component: selector Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

var replacingHtml = "<tr colspan='15'><table width='100%' height='350' data-replaced='true' data-rep='" + product_id + "'><tr><th class='system_header'>Financier name</th><th class='system_header'>Address</th><th class='system_header'>Contact number</th><th class='system_header'>Fax number</th><th class='system_header'>Email</th><th class='system_header'>Region</th></tr></table></tr>";

alert($(replacingHtml).find("[data-replaced='true']").length);

Change History (3)

comment:1 Changed 7 years ago by anonymous

http://jsfiddle.net/nanoquantumtech/j8Q3C/

var replacingHtml = "<tr colspan='15'><table width='100%' height='350' data-replaced='true' data-rep='" + product_id + "'><tr><th class='system_header'>Financier name</th><th class='system_header'>Address</th><th class='system_header'>Contact number</th><th class='system_header'>Fax number</th><th class='system_header'>Email</th><th class='system_header'>Region</th></tr></table></tr>";

alert($(replacingHtml).find("[data-replaced='true']").length);

http://jsfiddle.net/nanoquantumtech/j8Q3C/

comment:2 Changed 7 years ago by anonymous

I'm pretty sure that's not valid HTML

http://www.w3.org/TR/html401/struct/tables.html#h-11.2.5

If you console.log the element that results from that HTML, it doesn't contain the table element since it's not valid which is why it doesn't find the data-replaced attribute on it.

comment:3 Changed 7 years ago by sindresorhus

Component: unfiledselector
Priority: undecidedlow
Resolution: invalid
Status: newclosed

As anonymous said, not valid HTML. If you console.log() it, it will output:

<tr>​
    <th class=​"system_header">​Financier name​</th>​
    <th class=​"system_header">​Address​</th>​
    <th class=​"system_header">​Contact number​</th>​
    <th class=​"system_header">​Fax number​</th>​
    <th class=​"system_header">​Email​</th>​
    <th class=​"system_header">​Region​</th>​
</tr>​
Note: See TracTickets for help on using tickets.