jeudi 29 janvier 2015

Conditional jquery element selection


I have a table:



<table id="codexpl">
<tr>
<th>#</th>
<th>Columna</th>
<th>Relative</th>
<th>Isso</th>
</tr>
<tr>
<td>1</td>
<td>This</td>
<td>http://ift.tt/1ysHd2C;
<td>Is</td>
</tr>
<tr>
<td>2</td>
<td>Coloumn</td>
<td>two</td>
<td>this</td>
</tr>
<tr>
<td>3</td>
<td>http://ift.tt/1ysHd2C;
<td>not equals</td>
<td>a</td>
</tr>
<tr>
<td>4</td>
<td>the</td>
<td>Column</td>
<td>real</td>
</tr>
<tr>
<td>5</td>
<td>first</td>
<td>One</td>
<td>Coloumn</td>
</tr>


I'd like to select only the tds that have urls in them and change their contents with



$("td").each(function(){
$('<div class="box"><iframe src="' + this.href + '" width = "500px" height = "500px"></iframe></div>').insertAfter(this);
});


I've selected them before using jquery that looks like:



$('td').hover( function() {
var contents = $( this ).html() ;
if (contents.match("^http")) {


I'm wondering if you do something like this pseudocode:



$('td' WHERE innerhtml=="^http"){....




Aucun commentaire:

Enregistrer un commentaire