Attaching an Href to a row inside a table - html

I am using html in a .php file to code. I have a statement:
<html>
<tr>
<td>Hi<td>
<td>Test<td.
</tr>
</html>
How can I attach an href to the row? Simply adding href in the tag didn't work. Anybody know how? Note: The table was defined earlier in the code this is the snip-it portion of the row.

You do not attach href to row instead you better do as
<table class="table table-stripped">
<tr class="selectedRow">
<td>Hi</td>
<td>Test</td>
</tr>
</table>
then using jquery :
$('.selectedRow').click(function(){
alert('do something');
});
View LiveWeave

Related

Table row inside an anchor tag: Angular 4

I have a table which has [routerLink] on each <tr>. But, since there is no tag, I don't see the option "open link in a new tab" on right click. I tried surrounding the table row inside <a> tag but that just messes up all the CSS styles.
Is there a better/standard solution to tackle this issue?
This is what I tried:
<table>
<tr [routerLink]="url">
<a>
<td></td>
</a>
</tr>
.......
You can add a hyperlink inside the <tr> tag as follows,
<tr>
<td>
<a [routerLink]="url"> {{yourvalue}}
</a>
</td>
</tr>
You can try window.open() on click of each row.

Multiple thead getting created in DOM

Is there anything wrong with the HTML below?
It creates two thead's in the DOM.
The source (Ctrl+U) looks okay - exactly how I've written.
I am using Firefox.
<html>
<body>
<table id="interactions" class="tablesorter" style="width:600px; height=1024px">
<thead>
<tr>
<th width="800">Charts</th>
<th width="20">Chi Square p-value</th>
</tr>
<thead/>
<tbody></tbody>
</table>
</body>
</html>
Here's screenshot of DOM for the HTML.
<thead/> is a self-closing tag, not a closing tag.
Since <thead>s cannot be nested, the parser implicitly closes the previous tag first.
Move the /.

Add a table before innerHTML=xmlhttp.responseText;

I'm calling a table from a remote server like this
document.getElementById("datatable").innerHTML=xmlhttp.responseText;
but I'm wondering if I want to add a title on top of this table how is that coded? I'm thinking of adding a table and putting that title in
<table>
<tr>
<td>Title of the Table</td>
</tr>
</table>
I would use the <th> html element.
If JQuery is an option, it becomes very easy:
$(document).ready( function() {
$('#datatable').prepend('<thead><tr><th>Title</th></tr></thead>');
});

backbone js append view [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Backbone js: How to remove extra tag in view?
How come whenever I append a new backbone view to an HTML element, it automatically surrounds this view with a <div> </div>?
For example I have a table in my HTML page
<table class="table table-hover">
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
</tr>
</thead>
<tbody id="tbl">
</tbody>
</table>
Now in my backbone controller, I perform the following
$("#tbl").append(new tblview().render().el);
and in the actual view's HTML template I have
tblview.html
<tr>
<td>entry3</td>
<td>entry4</td>
</tr>
Now when i look at this in the browser, and inspect the html element.. it renders like this:
<table class="table table-hover">
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
</tr>
</thead>
<tbody id="tbl">
<div>
<tr>
<td>entry3</td>
<td>entry4</td>
</tr>
</div>
</tbody>
</table>
and thus is becomes all out of line? How can I fix this issue??
I want it to render the view without these extra <div> </div> in the table.
Backbone automatically create a div to surround any view. To overwritte the default, you need to set the tagName attribute when you extend a view. http://backbonejs.org/#View-extend
Backbone.View.extend({
tagName: "tr"
});
Your template doesn't need to include the tr tags. tblView should have tagName set to tr.

How to get access to no-existing tag?

If you create following HTML below:
<table>
<tr>
<td></td>
<td>Last1</td>
<SPAN><FONT>test1</FONT></SPAN>
</tr>
</table>
and check DOM model you will see that IE(maybe others) create tag with no-name.
Here is link to screenshot Screenshot:
Are there any possibility to get access to this tag or not ?
Your HTML is invalid.
You can only put <td> and <th> elements directly inside <tr>s.
The browser is creating this tag in an attempt to fix your broken markup.
You should correct your HTML.