Преобразование “document.getElementById” в jQuery

@Grant является правильным.

я нахожусь в команде с близко к 100 другим разработчикам, и наши файлы конфигурации не проверяются в управление исходным кодом. У нас есть версии файлов в репозитории, которые вытягивают с каждым выездом, но они не изменяются.

Это удалось вполне прилично для нас.

6
задан homework 12 September 2009 в 00:22
поделиться

3 ответа

The answer to your question (title) is to replace

document.getElementById('about').href = '#';

with

$('#about').attr('href','#');

I have no idea if this will actually help you solve your problem, though, since I really don't know what you are trying to do. Based on your comments and code sample, it appears that you are trying to do some sort of wizard, but I have no idea how it would actually work given what you've posted.

Update:

Maybe something like:

<a href="link.php?test=true" onclick="request(this)" target="_blank" class='request'></a>

<a id="step2" href="next.php">Step 2</a>

<script language="javascript">
    $(function() {
       var requests = 16;
       $('#step2').click( function() {
           alert('Not finished');
           return false;
       });
       $('.request').click( function() {
           var $this = $(this); // save jQuery reference to element clicked

           // swap indicator image source
           $this.find('img:first').attr('src','images/clear.gif');

           // if the number of flipped indicators equals the number of requests
           // remove the click handler from the step 2 link
           // this removes the alert and allows the user to proceed
           if ($('.request img[src="images/clear.gif"]').length == requests) {
              $('#step2').unbind('click');
           }

           ...do something with the href for this request via ajax???

           // replace this handler with one that simply returns false
           // and remove the href since we're done with this request
           $(this).unbind('click').attr('href','#').click( function() { return false; } );

            // stop the default action for the request
           return false;
    });
</script>
10
ответ дан 8 December 2019 в 17:24
поделиться

Нравится? Я думаю, что что-то упускаю / не понимаю ...

$('#about').click( function(evt) {
   request(this);
 });
2
ответ дан 8 December 2019 в 17:24
поделиться

This? Not sure I fully get what you want

function request(element)
{
    $(element).doSomething();
    return false;
}

invoked by:

onclicked="return request(this);"
0
ответ дан 8 December 2019 в 17:24
поделиться
Другие вопросы по тегам:

Похожие вопросы: