Got 3 cascading dropdowns (Clients -> Departments -> Teams) and loading their data using jquery ajax calls. (there are a lot to the rest of the form though, though not related to this problem )

Since I am clearing dropdowns and hiding elements all over, I wanted to created a function that can be called any time that will do that in one place). however I soon got stuck.

The following code works perfectly, until I one uncomment the alert. From then, the next line seems to just get ignored.

function SetControlsVisibility() {
    var clientId = $("select#ClientId > option:selected").attr("value");
    if (clientId == '' || clientId == undefined) {
        $('#DepartmentId').empty().prev().text("");   // ain't do it if no alert....
got a strong feeling of devaju here, but just cannot remember where I ran into this issue before though.