skip to Main Content

I have this attribute element and I want to extract the value from it.
I’m not sure how will I do it?
I want to extract value from

<select name="Hello/1.0/TestWorld" size="1" disabled="disabled" data-original-title="" title="">
  <option value=""></option>
  <option value="Hello">Hello</option>
 </select>

<script>
$(document).ready(function(){
  const hello = $('qualifier="Hello/1.0/TestWorld"')

  console.log('HELLO', hello)
    });
</script>

2

Answers


  1. You can access it like this (referred to your original request):

    <html>
    
    <head>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    </head>
    
    <body>
        <div class="helloDiv">
            <attribute qualifier="Hello/1.0/TestWorld" editable="false"></attribute>
        </div>
    
        <script>
            $(document).ready(function () {
                const hello = $('.helloDiv attribute');
    
                console.log('HELLO ', hello.attr('qualifier'), hello.attr('editable'));
            });
        </script>
    </body>
    
    </html>
    Login or Signup to reply.
  2. $(document).ready(function(){
      const elem = jQuery('[name="Hello/1.0/TestWorld"]');
    
      console.log(`HELLO: "${elem.val()}"`)
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    
    <select name="Hello/1.0/TestWorld" size="1" disabled="disabled" data-original-title="" title="">
      <option value=""></option>
      <option value="Hello">Hello</option>
     </select>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search