<!DOCTYPE html>
<html>
<head>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
function preview(){
temp = $(this).innerHTML;
testwin= open("", "testwin","status=no,menubar=yes,toolbar=no");
testwin.document.open();
testwin.document.write(temp);
testwin.document.close();
}
</script>
<table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
<tbody>
<tr>
<td onclick="preview()">dghfh</td>
</tr>
</tbody>
</table>
</html>
Pass a parameter to the function preview() you declared, then give the parameter value to the variable temp, and finally change the call to onclick=" preview(this.innerHTML)".
Personal test, it works
As for $(this).innerHTML This in is the browser object, not the jq object
The function preview written in onclick on the element points to the global object window, not to the element
$(this) is a jq object, so use $(this).html()
$(this)[0].innerHTML; like this
You can stop and take a look at what $(this) you wrote is, it should refer to window, not the td you want
$(this) is the context environment wrapped by jquery, and its specified method is required to obtain the internal static fragment.
Two ways to obtain:
Native writing: this.innerHTML
jquery: $(this).html()
jq+Native: $(this)[0].innerHTML or this.get(0).html()
Do you want native or jq