0

I have a problem with running jquery:

    <!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script type="text/javascript" src="jQuery.js"></script>
      <script type="text/javascript">
       $(function(){

            $('form').attr('id','myNewId');
        });
       </script>
    </head>
    <body>

        <div align="center">
            <form id="myID">
            My Name: <input type="text" name="text"/>
            </form>

        </div>
    </body>
</html>

no error happens , and no intellisense with netbeans..why the code doesnt work ?!?

UPDATE: now it works..

No intellisense with Netbeans..Here is my version:

> Product Version: NetBeans IDE 7.1.1 (Build 201203012225)
Java: 1.7.0_03; Java HotSpot(TM) Client VM 22.1-b02
System: Windows XP version 5.1 running on x86; Cp1255; en_US (nb)
User directory: C:\Documents and Settings\dddddddddddd\.netbeans\7.1.1
Cache directory: C:\Documents and Settings\dddddddddddd\.netbeans\7.1.1\var\cache
9
  • Works for me (in Chrome at least) Commented Mar 19, 2012 at 11:18
  • delete the $(function(){ and }); lines and try again. what happens? Commented Mar 19, 2012 at 11:19
  • yes it works as @qwertymk says. Commented Mar 19, 2012 at 11:20
  • 1
    ID is changed. How are you checking out if it is or not? Use Firebug or Chrome dev tools and you will verify that myNewId is set as form ID. Commented Mar 19, 2012 at 11:21
  • 1
    tpaksu nothing happens... I dont think jquery is loaded.. firebug tells me:$ is not defined Commented Mar 19, 2012 at 11:28

2 Answers 2

2

jQuery Intellisense is already available on Netbeans. [read more]

It should work the way you are coding [demo], but as of jQuery 1.6+ , you can also use .prop() to set values for attributes[demo]

$('form').prop('id','myNewId');

In case jQuery is not defined, may be it is conflicting with a different jQuery version. Use this at the top of your script

  $.noConflict();
Sign up to request clarification or add additional context in comments.

21 Comments

Shouldn't be .prop only used for things like selectedIndex, tagName, nodeName,... ? So to speak only for properties, and id would be an attribute.
firebug tells me: $ is not defined.. is jquery not loaded
@BlackFire27, on my demo or while you are using
@BlackFire27, It seems the script is conflicting. Check my update
It tells me that $ isnt defined on $.noConflict
|
0

Dude Its working fine for me. Make sure you jQuery.js file is located in the appropriate location and also named correctly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.