--- id: bad87fee1348bd9aed808826 title: Disabilitare un elemento usando jQuery challengeType: 6 forumTopicId: 17563 dashedName: disable-an-element-using-jquery --- # --description-- Con jQuery è anche possibile modificare le proprietà non-CSS degli elementi HTML. Ad esempio, è possibile disabilitare i bottoni. Se disattivi un bottone, esso diventerà grigio e non potrà più essere cliccato. jQuery ha una funzione chiamata `.prop()` che consente di regolare le proprietà degli elementi. Ecco come disattivare tutti i bottoni: ```js $("button").prop("disabled", true); ``` Disabilita solo il bottone `target1`. # --hints-- Il bottone `target1` dovrebbe essere disabilitato. ```js assert( $('#target1') && $('#target1').prop('disabled') && code.match(/["']disabled["'],( true|true)/g) ); ``` Nessun altro bottone dovrebbe essere disabilitato. ```js assert($('#target2') && !$('#target2').prop('disabled')); ``` Dovresti usare solo jQuery per aggiungere queste classi all'elemento. ```js assert(!code.match(/disabled[^<]*>/g)); ``` # --seed-- ## --seed-contents-- ```html

jQuery Playground

#left-well

#right-well

``` # --solutions-- ```html

jQuery Playground

#left-well

#right-well

```