This article mainly introduces the implementation of searching for element a through url to solve some practical problems. If you are interested, refer to the following example to illustrate a previous project: when adding students, no class data. You need to automatically jump to the class display page.
Problem: students, classes, and other data are stored in the jsp file of iframe. The student management button is in the menu bar of main.html.
Mian page menu
Class Management:
Student Management:
The jsp in iframe is constantly changing.
Solution:
In Student Management jsp, find the class management tag of the parent form by id, and click
The Code is as follows:
Vertex (window.parent.doc ument). find ("# folder_12"). click ();
Later, the menu bar is changed to dynamic, and the menu id is also dynamic.
What you want is to get it through the url and click.
The Code is as follows:
Class Management
The value to be obtained is the changeContent ('url parameter') of The onClick method ')
View the Code directly:
The Code is as follows:
// Lele.info (subject (window.parent.doc ument). find (""));
Vertex (window.parent.doc ument). find ("# OutFolder a"). each (function (index, domEle ){
// Var s = $ (domEle). attr ("onclick") + "";
// Var start = s. indexOf ('classmanager/classList. do ');
Var str = domEle. attributes. onclick. value; // use js to obtain the onclick attribute value and search for the url
Var start = str. indexOf ('classmanager/classList. do ');
If (start> 0 ){
$ (DomEle). click ();
}
});
Summary: I used jquery to find the method and get the onclick attribute. I used indexOf to report an error and added a space to convert it to string.