Selecting an option by its text

后端 未结 2 1643
礼貌的吻别
礼貌的吻别 2021-01-23 11:42

I\'m developing a web page using django and I want to add some javascript to a form using jQuery. Basically I want to select an option in a form depending on an another selectio

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-23 12:18

    Just found something that works, using contains instead of the text='values' selector

    not working for me

    $("#id_adeudado option[text='{{ usuario.username }}']")
    

    working

    $("#id_adeudado option:contains('{{ usuario.username }}')")
    

提交回复
热议问题