DOM search for positive name and value

Asked

Viewed 112 times

3

I need to search DOM for name and value. I’m trying to do it like this

$('input[name=FLG_SEXOX_CLIEN value="{{ $cliente->FLG_SEXOX_CLIEN }}"]').attr('ckecked').trigger("chosen:updated");

However not working, on the console appears this message:

Error: Syntax error, unrecognized Expression: input[name=FLG_SEXOX_CLIEN value="M"]

How to solve this ?

  • 3

    Try: $('input[name="FLG_SEXOX_CLIEN"], input[value="{{ $cliente->FLG_SEXOX_CLIEN }}"]').attr('ckecked').trigger("chosen:updated");

3 answers

10


You have to separate the searches within different brackets:

$('input[name="FLG_SEXOX_CLIEN"][value="{{ $cliente->FLG_SEXOX_CLIEN }}"]').attr('ckecked').trigger("chosen:updated");

Selector - Attribute Selectors

Multiple attribute selectors can be used to refer to several Attributes of an element, or Even several times to the same attribute.

Here, the selector Matches all SPAN Elements Whose "hello" attribute has Exactly the value "Cleveland" and Whose "Goodbye" attribute has Exactly the value "Columbus":

span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }

Or in free translation:

The selection of multiple attributes in the selector can be used to reference multiple attributes of an element, or even multiple times the same attribute.

Here, the selector combines all elements SPAN where the attribute "hello" has the exact value "Cleveland" and the attribute "Goodbye" has the exact value "Columbus";

span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }

4

Syntax is wrong, to use multiples attributes is that way:

$('input[name="FLG_SEXOX_CLIEN"][value="valor_aqui"]');

2

Try it this way:

$('input[name=FLG_SEXOX_CLIEN][value=FLG_SEXOX_CLIEN]:checked').trigger("chosen:updated");

I do not understand very well what you intend to do, because it seems to me that you are trying to update the combo with the value selected in it, if that is the case just do so direct:

 $('#id-combo').trigger('chosen:updated');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.