In the background management of a blog, you can add an address for a category, but it is difficult to add an onclick event. If you want to pass the current object to a function, you can write the URL as "Javascript: shoControlSidebar (this)". However, the result shows that this is not feasible. The previous parameter passed is an object, however, no other information is available. I want to get innerText, but this does not point to its A tag.
This is different from <a href = "Javascript: shoControlSidebar (this)"> <a href = "javascript: void (0)" onclick = "shoControlSidebar (this)">.
When onclick = "shoControlSidebar (this)" is used, the interpreter packs an anonymous function for it and changes it:
Copy codeThe Code is as follows:
A. onclick = function anonymous ()
{
ShoControlSidebar (this );
}
This refers to the object "a". When using href, this object has nowhere to be indicated because it is an address.
Copy codeThe Code is as follows:
<A href = "javascript: void (0);" onclick = "test (this);"> A tag test </a>
Copy codeThe Code is as follows:
To obtain innerHTML in
If href = "test (this);" does not get the value, and the program exits, href leads to an error.
Copy codeThe Code is as follows:
Function test (obj ){
Alert (obj );
// Js
Alert (obj. innerHTML );
// Jquery
Alert(objects (obj).html ());
}