Pergunta

I've spent many hours (days) searching for a solution and I've come up with no clear solution. I'm new to this so I might not know some basic procedures. I'm sure I'm making a very simple mistake hoping someone can help me out.

Basically I want to add text to an input field when you mouseover (or click) the submit button. I think the code is correct:

$(document).ready(function(){
    $('input[name="submitButton" ').mouseenter(function(){
        $('input[name="form[element0]" ').value($('input[name="form[element0]" ').value() + "extra text added") ;
    });
});

What I think is the problem is that I can't modify the html directly with rapidweaver so I can't put the script source where I want it. I can only add things to the header, css, JavaScript tags, but nothing directly to the body. What happens is JavaScript gets loaded before the jQuery library. But i'm not sure if this is the problem or not.

This is added to the very bottom of the header:

<script type="text/javascript" src="jquery-1.10.1.min.js" ></script>

I've also made sure the file is in the correct folder.

Any ideas on whats wrong, if it's my code or if I'm just not setting things up correctly?

Foi útil?

Solução 2

It turns out my solution to the problem was moving my code to the header with tags, and then add http:// to the front of my scr like so:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

More info here: http://forums.realmacsoftware.com/discussion/comment/248749#Comment_248749

Outras dicas

It depends if the header page was included before the code above was executed. So that it will not confuse you in selecting an html element, give an ID to that element and access with it.

e.g
   <input type = 'text' id = "txt1">
   <button id = "btnId"><Click Me</button>

and access it via jquery with this

$(document).ready(function() { 
    $('#btnId').click(function() { 
        $('#txt1').html('This will appear to the textbox!');
    });
});

If you have in internet connection, you can reference your jquery here so that you will not be confuse if where your jquery file was located.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top