javascript
  • jquery
  • html
  • css
  • codeigniter
  • 2017-06-08 55 views 1 likes 
    1

    的particualr div嗨,我需要重新加載一個特定的div沒有重新加載整個頁面。刷新一個重複整個頁面在php

    <div class=""> 
             <div class="contactpagecaptchas"> 
              <img src="/captcha.php?rand=<?php echo rand();?>" class="contactpagecaptchass" id='captchaimg'/> 
              <p class="change"><a href="javascript: refreshCaptcha();" class="clickto">Click to change</a></p> 
             </div> 
    
             <div class="contactcaptcha"> 
              <input type="text" class="form-control" name="captcha" placeholder="Captcha" style="background-color: #f4f4f4;border: none;"> 
             </div> 
            </div> 
    

    一旦我上刷新驗證碼文本框中單擊應該得到cleared.Can任何一個可以幫助我這一個

    +0

    執行'ajax'調用您的服務器端'php'方法.. –

    +0

    其實我試着用一些代碼,但沒有工作 – user8001297

    +1

    你能告訴你已經試過了嗎? –

    回答

    2

    $('.clickto').click(function() { 
     
        $('[name="captcha"]').val(''); 
     
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
     
    <div class=""> 
     
        <div class="contactpagecaptchas"> 
     
        <img src="/captcha.php?rand=<?php echo rand();?>" class="contactpagecaptchass" id='captchaimg' /> 
     
        <p class="change"><a href="#" class="clickto">Click to change</a></p> 
     
        </div> 
     
    
     
        <div class="contactcaptcha"> 
     
        <input type="text" class="form-control" name="captcha" placeholder="Captcha" style="background-color: #f4f4f4;border: none;"> 
     
        </div> 
     
    </div>

    +1

    謝謝你的工作 – user8001297

    0

    嘗試的JavaScript的onclick方法

    <div id="abc" ><?php echo rand(); ?></div> 
    <button onclick="refcaptcha()" > 
    <script> 
    function refcaptcha(){ 
        var x = document.getElementById("abc") 
        x.innerHTML = Math.floor((Math.random() * 1000000) + 1); 
        //if you want to clear the captcha code than assign '' to that id 
        //x.innerHTML = ''; 
    } 
    </script> 
    
    相關問題