Find a element by URL and click _jquery

Source: Internet
Author: User
Give an example of a previous project: When you add a student, there is no class data. Need to automatically jump to the class display page.

Question: Students, classes and other data is placed in the IFRAME inside the JSP. The student-managed button is on the Main.html menu bar.

Workaround:

Find the parent form's class management <a> tags by ID and click
Copy Code code as follows:

$ (window.parent.document). Find ("#folder_12"). Click ();

Later, the menu bar changed to dynamic, menu ID is also the dynamic of nature.

Want is to get <a&gt by URL, and click.
Copy Code code as follows:

<a id= "folder_14" onclick= "removetopmenucss (); Switchfolder (this.id); Changecontent (' Classmanager/classlist.do ' , this); "onfocus=" This.blur () "href=" javascript:void (0); "target=" MainFrame "> Class management </a>

To get is the changecontent (' url parameter ') of the OnClick method

Look directly at the code:
Copy Code code 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 onclick property value, search URL
var start = Str.indexof (' classmanager/classlist.do ');
if (start>0) {
$ (Domele). Click ();
}
});

Summary: The original has been using jquery to find ways to get the OnClick property, with indexof total error, plus "" space into string on the line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.