Move you common functionality into it's own function

like

function DoSomething() {
    var $drp = $("#properties div select");
    var val = $drp.val();
    var txt = $drp.find("option:selected").text();

    // Do some code with the <select>
}

and as long as the code is inside $(document).ready, then you can say

$(document).ready(function() {
      $("#properties div select").change(DoSomething);
      DoSomething();
});

because when the document is "ready", then the select is also "ready"

On Jan 8, 4:19 am, lsblsb <[email protected]> wrote:
> hi there,
>
> i want to execute the same lines of code when the site has finished
> loading AND when an onchange-event is fired.
>
> i tried something like
>
> $("#properties div select").bind("ready change",function(e){
> $("#properties div select").bind("load change",function(e){
>
> but this does not work :/
>
> can you tell me how to do something like that?
>
> thank you!

Reply via email to