none
How can i get a herf to textbox from webpage RRS feed

  • Question

  • Hello,

    i have button in webpage how can i get the link from the button

    <a href="https://sample/com/lookwide;ses=042a768625ea3d529c503f8f28088023&amp;has_bvc=0" class="bui-button bui-button--secondary bui-button--wide" target="_blank"><!----> <span class="bui-button__text"><span> Click me</span></span></a>
    how can i get the link from the button Click me into textbox

    Thursday, November 21, 2019 1:22 AM

Answers

  • Hi,

    According to your description, I suggest you could try to use jquery to achieve your requirement. You could add a id attribute for the a tag and use jquery class selector to locate the click me span tag, then you could bind click function to that span to get the a tag value.

    More details, you could refer to below codes:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"
                integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
                crossorigin="anonymous"></script>
        <script>
            $(function () {
                $(".bui-button__text").click(function () {
                    $("#Text1").val($("#Value1").attr("href"));
                   
                });
            });
          
        </script>
    </head>
    <body>
        <a id="Value1" href="https://sample/com/lookwide;ses=042a768625ea3d529c503f8f28088023&amp;has_bvc=0" class="bui-button bui-button--secondary bui-button--wide" target="_blank">
            <!---->
            <span class="bui-button__text">
                <span> Click me</span>
            </span>
        </a>
        <input id="Text1" type="text" />
    </body>
    </html>
    

    Result:

    Hope it helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 21, 2019 7:33 AM
    Moderator

All replies

  • Hi,

    According to your description, I suggest you could try to use jquery to achieve your requirement. You could add a id attribute for the a tag and use jquery class selector to locate the click me span tag, then you could bind click function to that span to get the a tag value.

    More details, you could refer to below codes:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"
                integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
                crossorigin="anonymous"></script>
        <script>
            $(function () {
                $(".bui-button__text").click(function () {
                    $("#Text1").val($("#Value1").attr("href"));
                   
                });
            });
          
        </script>
    </head>
    <body>
        <a id="Value1" href="https://sample/com/lookwide;ses=042a768625ea3d529c503f8f28088023&amp;has_bvc=0" class="bui-button bui-button--secondary bui-button--wide" target="_blank">
            <!---->
            <span class="bui-button__text">
                <span> Click me</span>
            </span>
        </a>
        <input id="Text1" type="text" />
    </body>
    </html>
    

    Result:

    Hope it helpful.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 21, 2019 7:33 AM
    Moderator
  • Thank u so much
    Thursday, November 21, 2019 7:48 PM