Home > Web Front-end > JS Tutorial > Find a element by url and click _jquery

Find a element by url and click _jquery

WBOY
Release: 2016-05-16 16:53:06
Original
1462 people have browsed it

Let’s give an example of a previous project: when adding students, there was no class data. Need to automatically jump to the class display page.

Problem: The student, class and other data are placed in jsp inside the iframe. The button for student management is in the menu bar on main.html.

Solution:

Find the class management tag of the parent form by id, and click

Copy code The code is as follows:

$(window.parent.document).find("#folder_12").click();

Later, the menu bar was changed to dynamic, and the menu id was naturally dynamic.

What you want is to get through the url and click.
Copy code The code is as follows:

What you want to get is the changeContent('url parameter') of the onClick method

Look at the code directly:
Copy code The code is as follows:

//console.info( $(window.parent.document).find("a") );
$(window.parent.document).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 get the onclick attribute value, search url
var start = str.indexOf (''classManager/classList.do');
if(start>0){
$(domEle).click();
}
});

Summary: I used to use jquery to find a way to get the onclick attribute. I used indexOf to always report an error. Just add "" and convert the spaces into strings.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template