JSFiddle - React, Tailwind, and code Playground
by laubstein
HTML
<div id="container"></div>
<div id="result"></div>
JavaScript
/**
* author: @laubstein
* date: Mar 11 2011
* title: jQuery :not(:first) problem in IE
*
* The code bellow create, dynamically, "qtd" copies of a specific html
* element and append them to the div with id "container".
* After that I use two different selectors to get all appended elements
* but the first.
* If you try to run this code using IE, you will see that the first kind
* of selector does not work with div's elements.
**/
// return list of ids
function getIds(els) {
var ret = [];
els.each(
function() {
ret.push(this.id);
}
);
return ret.join(',');
}
// get result string
function getResult(els, qtd, tag) {
// change to show just wrong results
var just_wrong = false,
ok = (qtd - 1) == els.size();
return ((ok && !just_wrong) || !ok) ?
((ok ? 'OK' : 'WRONG') + ' => found ' + els.size() + ' expected ' + (qtd - 1) + ' [' + tag + '] - ' + getIds(els)) :
' ';
}
var qtd = 10,
result_t1 = ['<pre>'],
result_t2 = ['<pre>'],
result_t3 = ['<pre>'],
not_first = 0,
ret = ' ',
tags = ['a', 'abbr', 'acronym', 'address', 'b', 'blockquote', 'button',
'caption', 'div', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'hr', 'img', 'input', 'label', 'legend', 'li', 'link', 'option',
'p', 'pre', 'select', 'span', 'sub', 'sup', 'table', 'textarea',
'ul'];
result_t1.push('<b>USING EXPRESSION:</b> $(\'<i>TAGNAME</i>.child:not(:first)\')');
result_t2.push('<b>USING EXPRESSION WITH CONTEXT:</b> $(\'<i>TAGNAME</i>.child:not(:first)\', \'#container\')');
result_t3.push('<b>USING:</b> $(\'<i>TAGNAME</i>.child\').not(\':first\')');
for (var idx in tags) {
var tag = tags[idx];
$('#container').empty();
for (var i=1; i<=qtd; i++) {
$('#container').append('<' + tag + ' class="child" id="' + i + '">' + i + '</' + tag + '>');
}
// ----------
// first test
// ----------
not_first =...