3

Simple jquery is that a way to change the text on href after onclick that particular in a href li ?

what i wish to do is , once clicked on the button in li href the particular word of "点击查询" will change to "0.00". Kindly advise

my HTML :

<div class="mmenu mmenu_movie">
        <div class="mm_header">
            <ul>
                <li>游戏余额</li>
            </ul>
            <div class="mm_exit"></div>
        </div>
        <div class="be_main" id="showmethemoney">
            <ul>
                <li>EA真人:<a id="eabal">点击查询</a></li>
                <li>BBIN真人:<a id="bbinbal">点击查询</a></li>
                <li>AG真人:<a id="agbal">点击查询</a></li>
                <li>EBET平台:<a id="ebetbal">点击查询</a></li>
                <li>体育平台:<a id="sbbal">点击查询</a></li>
                <li>LB彩票:<a id="lbbal">点击查询</a></li>
                <li>KG彩票:<a id="kgbal">点击查询</a></li>
                <li>AMP时时彩:<a id="ampbal">点击查询</a></li>
                <li>棋牌游戏:<a id="chbal">点击查询</a></li>
                <li style="margin-bottom: 20px;">PT平台:<a id="ptbal">点击查询</a></li>
            </ul>
        </div>
    </div>

jQUERY :

$(".be_main a").click(function () {
                var gp = $(this);
                var act = gp.attr("id");
                $("#loading").show();
                     $("#showmethemoney a").text('0.00');
                    });
                    complete: function (XMLHttpRequest, status) {
                        $("#loading").hide();
                        if (status == 'timeout') {
                            alert("加载超时");
                        }
                    }
                });
            });


        });

2 Answers 2

1

What you could do is add $(this).text('0.00') to your click-function. I guess you need a event.preventDefault because otherwise you would navigate away from the page and never see the change of text.

$(".be_main a").click(function (event) {
   event.preventDefault();

   var gp = $(this);
   gp.text('0.00');
})
Sign up to request clarification or add additional context in comments.

Comments

1

Your gp variable will be the jQuery wrapped anchor element that is clicked on, so just use the jQuery method .text() to change the text

gp.text("0.00");

Demo

$(".be_main a").click(function() {
  var gp = $(this);
  gp.text("0.00");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="be_main" id="showmethemoney">
  <ul>
    <li>EA真人:<a id="eabal">点击查询</a>
    </li>
    <li>BBIN真人:<a id="bbinbal">点击查询</a>
    </li>
    <li>AG真人:<a id="agbal">点击查询</a>
    </li>
    <li>EBET平台:<a id="ebetbal">点击查询</a>
    </li>
    <li>体育平台:<a id="sbbal">点击查询</a>
    </li>
    <li>LB彩票:<a id="lbbal">点击查询</a>
    </li>
    <li>KG彩票:<a id="kgbal">点击查询</a>
    </li>
    <li>AMP时时彩:<a id="ampbal">点击查询</a>
    </li>
    <li>棋牌游戏:<a id="chbal">点击查询</a>
    </li>
    <li style="margin-bottom: 20px;">PT平台:<a id="ptbal">点击查询</a>
    </li>
  </ul>
</div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.