thommylue
thommylue

Reputation: 170

Jquery does work on JSfiddle but doesnt on server

i have a basic jquery and html code, when i paste in in JSfiddle and select the library "jquery-ui-1.9.2.min.js" it works. But when i dont select a library, but link a script from my server it doesn't work...

I checked the request, and the server gave an answer with the correct library...

<script type="text/javascript">
    $(document).ready(function () {
        $('#NewCustomerDiv input[name="companyname"]').keyup(function () {
            if ($(this).val() == "") {
                $('#CustomerCompanyDiv').slideUp("slow");
            } else {
                $('#CustomerCompanyDiv').slideDown("slow");
            }
        });
        if ($('#NewCustomerDiv input[name="companyname"]').val()) {
            $('#CustomerCompanyDiv').slideUp("slow");
        }
        $(".compname").click(function () {
            $(this).select();
        });
    });
</script>

<div id="NewCustomerDiv" <tr>
    <td class="fieldlabel field0a">Bedrijfsnaam</td>
    <td class="fieldlabel field0b" colspan="3">
        <input type="text" name="companyname" tabindex="3" style="width:80%;" />
        <p style="margin-left:50px; display:inline;">Indien van toepassing</p>
    </td>
    </tr>
    <div id="CustomerCompanyDiv" style="display:none;">
        <input type="text" name="veld1" />
        <input type="text" name="veld2" />
    </div>
</div>

Here's the jsfiddle

JSFIDDLE

Upvotes: 1

Views: 82

Answers (2)

Merlin
Merlin

Reputation: 4917

You didn't close the first <div> and forget the <table> tag

FIDDLE

HTML

<div id="NewCustomerDiv">
    <table>    
        <tr>
            <td class="fieldlabel field0a">Bedrijfsnaam</td>
            <td class="fieldlabel field0b" colspan="3">
                <input type="text" name="companyname" tabindex="3" style="width:80%;" /> 
                <p style="margin-left:50px; display:inline;">Indien van toepassing</p>
            </td>
        </tr>
    </table>    
    <div id="CustomerCompanyDiv" style="display:none;">
        <input type="text" name="veld1" />
        <input type="text" name="veld2"/>
    </div>
</div>

JAVASCRIPT

$(document).ready(function(){

    $('#NewCustomerDiv input[name="companyname"]').keyup(function(){    
         if($(this).val()==""){
              $('#CustomerCompanyDiv').slideUp("slow");
         }
         else{
            $('#CustomerCompanyDiv').slideDown("slow");
         }
    });

    if($('#NewCustomerDiv input[name="companyname"]').val()){
         $('#CustomerCompanyDiv').slideUp("slow");
    }

    $(".compname").click(function(){
        $(this).select();
    });
});

Upvotes: 1

Farzad
Farzad

Reputation: 852

Did you included the JQ file at the top of the page ?

May be the problem is because you didn't closed the opening of this tag : (line 24)

<div id="NewCustomerDiv"

Also You have to put the table tags (tr , td) into <table> tag.


Check this : jsfiddle

Upvotes: 2

Related Questions