April 4, 2012

How do I make bootstrap table rows clickable?

Question by rjurney

I can hack this myself, but I think bootstrap has this capability.

Answer by Terry

Using jQuery it’s quite trivial. v2.0 uses the table class on all tables.

$('.table > tr').click(function() {
    // row was clicked
});

Answer by Starx

May be you are trying to attach a function when table rows are clicked.

var table = document.getElementById("tableId");
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
    rows[i].onclick = functioname(); //call the function like this
}

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!