function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } var first = getUrlVars()['card']; var index = $('td').index(first); 

  • one
    the foreach loop returns the element index of the element itself and the enumerated array. From this it follows that you can go through the array and watch the id attribute, if you match, return the index of the element. - pepel_xD
  • it would be better to have the input url, and what should be the output. - teran 2:58
  • Instead of the whole construction with location.href.indexOf it would be worth using location.search :) - Yaant

0