mardi 14 juin 2016

jQuery: find last 4 letters in string, append it to url, make that row clickable link


Hi i'm struggling to make a few separate elements work together to get the final result:

1/ i'm making a variable 'ginfo' - the last 4 letters from a string in a table row

2/ I want to make that row a url, using myurl + ginfo

pretty simple separately, just get it all to work together... thanks for your input!

<script>

//define 'ginfo' from the table id 'airt' and in the cell 
//containing 'G-' find the last 4 letters.

jQuery var ginfo =("#airt td:contains('G-')").substr(-4);


// now find the same cell, and append 'ginfo' to the supplied link

jQuery("#airt td:contains('G-')").click(function(){ 

window.location = ('http://mycustomlink.com/', 'ginfo'); 
  
});

</script>

Aucun commentaire:

Enregistrer un commentaire