Ciao a tutti
Devo prelevare il testo, del valore selezionato, di una select, o provato così:
ma non mi da nullacodice:$("select[name=category]").change(function(){ var text=$(this).is(":selected").text(); alert(text); }
Ciao a tutti
Devo prelevare il testo, del valore selezionato, di una select, o provato così:
ma non mi da nullacodice:$("select[name=category]").change(function(){ var text=$(this).is(":selected").text(); alert(text); }
Dovrebbe essere:
codice:$("select[name=category]").change(function(){ var text=$('option:selected',$(this)).text(); alert(text); }
un ultima domanda posso passare un oggetto tra due funzioni tipo:
codice:var obj=$(this); newfuc(obj, "testo");
e non me lo passa perche?
leggo questo in html:
deleteCat([object Object], '1', 'Calzature', 'Calzature')
codice:$("body").on("click",".del-cat", function(e){ e.preventDefault(); var obj=$(this); var act=$(this).attr("data-act"); var text=$(this).parent("div").text(); switch(act){ case "0" : var id=$(this).attr("data-id"); var text1="Categoria"; var text3="Eliminando la Categoria verranno eliminate automaticamente anche le ripsettive Sotto Categorie, proseguire?"; break; case "1" : var id=$(this).attr("data-sc"); var text1="Sotto Categoria"; var text3=""; break; } var text2=$(this).parent("div").text(); warning_alert("<div>Sei sicuro di volere eliminare la " + text1 + " \"" + text2 + "\"</div><div>" + text3 + "</div>","deleteCat(" + obj + ", '" + act + "', '" + id + "', '" + text + "')"); e.stopPropagation(); }); }); function deleteCat(obj, act, id, text){ closed_alert(); alert(obj.parent("div").text()); }
E infatti lo stai stampando a video, puoi passare un oggetto ad una funzione ma non puoi inserire una variabile oggetto in una stringa.