DOM search for name and value positive [duplicate]

3

I need to search the DOM for name and value. I'm trying to do this

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

But this is not working, in the console this message appears:

  

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

How to solve this?

    
asked by anonymous 08.12.2016 / 19:56

3 answers

10

You have to separate your searches into 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 "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 several attributes of an element, or even several times the same attribute.

     Here, the selector combines all SPAN elements in which the "hello" attribute has the exact "Cleveland" value and the "goodbye" attribute has the exact value "Columbus";

span[hello="Cleveland"][goodbye="Columbus"] { color: blue; }
    
08.12.2016 / 20:00
4

The syntax is wrong, so use multiple attributes this way:

$('input[name="FLG_SEXOX_CLIEN"][value="valor_aqui"]');
    
08.12.2016 / 20:00
2

Try this:

$('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 selected value in itself, if that is the case,

 $('#id-combo').trigger('chosen:updated');
    
08.12.2016 / 20:08