JavaScript How to find elements inside div by tag find elements inside element selenium,find elements inside iframe,find

When I am trying to do this:

var element_current_classes=($("#form_div :textarea").attr('class'));

or this:

var element_current_classes=($("#form_div :select").attr('class'));

I am getting this error - Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: textarea

It works only with 'input' and button

What I am trying to do is to find elements inside the form by their tags

Any ideas?

Answer:1

Correct way to select an html element is

var element_current_classes=($("#form_div textarea").attr('class'));
var element_current_classes=($("#form_div select").attr('class'));

Note: In jQuery for html tags and form elements we use name of the tag

$('div').hide(); // this code will hide all divs

Where as : is a selector that is use to get a specific tag or element

$('div:last').hide(); // this code will hide only last div
Answer:2

There is no selector called :textarea or :select - you can use element selector to select the textarea or select element

$("#form_div textarea").attr('class')
$("#form_div select").attr('class')

The :input pseudo selector used to select multiple kinds of input elements like input, select, textarea etc

Answer:3
var element_current_classes = $("#form_div select").attr('class');
Answer:4

you don't need : selector to get textarea or select . just use element selector. try this

 var element_current_classes=$("#form_div select").attr('class'); //select
 var element_current_classes=$("#form_div textarea").attr('class'); //textarea
Answer:5

I am trying to call JavaScript inside XSLT but it keeps on failing. I am using the Xalan namespace. I'm calling Java as well and that works no problem, but for some reason the JavaScript doesn't. <...

I am trying to call JavaScript inside XSLT but it keeps on failing. I am using the Xalan namespace. I'm calling Java as well and that works no problem, but for some reason the JavaScript doesn't. <...

  1. javascript include call function

I'm trying to make a program that you can enter the dimensions of a Rubik's cube eg. 13x13x13 and the program tells you how many permutations there are for that Rubik's cube. I have the math to figure ...

I'm trying to make a program that you can enter the dimensions of a Rubik's cube eg. 13x13x13 and the program tells you how many permutations there are for that Rubik's cube. I have the math to figure ...

I've got a range slider which I'm using to control a value in an input box. The values we're using can be quite high on the max end so we wanted finer control for smaller numbers before spanning out ...

I've got a range slider which I'm using to control a value in an input box. The values we're using can be quite high on the max end so we wanted finer control for smaller numbers before spanning out ...

The following code: console.log((var a=5; ++a)); Does not compile, because var is considered a statement, not a function. The following does compile: console.log((a=5, ++a)); And words as expected,...

The following code: console.log((var a=5; ++a)); Does not compile, because var is considered a statement, not a function. The following does compile: console.log((a=5, ++a)); And words as expected,...