Here's a short version:
$('#ddlCodes').change(function() {
$('#txtEntry2').text($(this).find(":selected").text());
});
karim79 made a good catch, judging by your element name txtEntry2
may be a textbox, if it's any kind of input, you'll need to use .val()
instead or .text()
like this:
$('#txtEntry2').val($(this).find(":selected").text());
For the "what's wrong?" part of the question: .text()
doesn't take a selector, it takes text you want it set to, or nothing to return the text already there. So you need to fetch the text you want, then put it in the .text(string)
method on the object you want to set, like I have above.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…