Find a element by URL and click

Source: Internet
Author: User

The

  Find A-element method is very right, you can pass the ID or class, but if neither of the two conditions, there is no way? NO, through the URL is also possible, here is a good example, you can feel the

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.     Questions: Students, classes and other data is placed in the IFRAME inside the JSP. The student-managed button is on the Main.html menu bar.     Solutions:    Class Management <a> label for parent form by ID, and click     code as follows: $ (window.parent.document). Find ("# Folder_12 "). Click ();    later menu bar changed to dynamic, menu ID is also dynamic.     Want to get <a&gt through the URL, and click.     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 obtain is the OnClick method of changecontent (' url parameters ')     directly look at the 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 '); nbsp 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: I've been using jquery to find ways , get the OnClick property, with indexof total error, plus "" space into a 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.