Note that there are some explanatory texts on larger screens.

plurals
  1. POHighlight a row of a table with JQuery / Bootstrap using anchors
    primarykey
    data
    text
    <p>I'm using Bootstrap (Twitter) and JQuery. I have a table with some data and each row has an id. I have a typeahead to search data in my table. When I select a data in my typeahead, I would like to highlight the correct row, that why I use the anchors. But, I don't know how to highlight the row.</p> <p>Here my JQuery code:</p> <pre><code>$(document).ready(function() { $('#typeahead').change(function() { window.location = "#" + $(this).val(); //highlighting the row... }); }); </code></pre> <p>This HTML code is just for testing:</p> <pre><code>&lt;a href="#row1"&gt;Row1&lt;/a&gt; &lt;a href="#row2"&gt;Row2&lt;/a&gt; &lt;table class="table table-hover table-bordered"&gt; &lt;tr id="row1"&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;/tr&gt; &lt;tr id="row2"&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Here the code for the typeahead:</p> <pre><code>&lt;input type="text" id="typeahead" data-provide="typeahead" placeholder="Search a name" data-items="4" data-source='[ &lt;?php for($i = 0 ; $i &lt; count($typeahead) ; $i++) { if($i+1 == count($typeahead)) echo '"'.$typeahead[$i].'"'; else echo '"'.$typeahead[$i].'",'; } ?&gt;]'&gt; </code></pre> <p>Here the content of the typeahead array:</p> <pre><code>&lt;input type="text" id="typeahead" data-provide="typeahead" placeholder="Search a name" data-items="4" data-source='["Christophe Chantraine","Toto Tuteur","Henris Michaux","Robert Patinson","Benjamin Brégnard","Jean-Charles Terzis","Ludovic Dermience","Claude Dianga"]'&gt; </code></pre> <p>Here is a sample code to introduce my problem: <a href="http://jsfiddle.net/TK7QP/6/" rel="nofollow noreferrer">http://jsfiddle.net/TK7QP/6/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload