简体   繁体   中英

how do find the value of closeText option in a web page with java script?

I would like to write a java script file that searches for closeText value and console.log it but i am a confused how to do this my approach is based on this documentation but i can't figure out how to do this, i all get is an error ReferenceError: $ is not defined

my problem

html.index file

<!DOCTYPE html>
<html>
  <script   src="https://code.jquery.com/jquery-1.4.2.js"></script>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>repl.it</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <iframe id=target ></iframe>

    <script src="script.js"></script>
  </body>
</html>

and the script.js

var target = document.getElementById('target');


var closeText = $( ".selector" ).dialog( "option", "closeText" );


console.log(closeText);

You need link JQuery before your code like bellow.

<script   src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script>
//your code here    
</script>

you can find your version of jquery from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM