I'm new to this website so I'm sorry if I do something wrong, please tell me if I do so.
Problem: I'm trying to get a href from the current page I'm on with a button like "Get Href" and when it manages to get a href it will display text Href gotten or if it fails it says Href not found. If it does find it a new button appears which says Goto Href and that takes the user to the href. I've been searching the whole week for a solution but so far I have no luck. Also this is a chrome extension.
Useful Links Found So Far:
- Need to link directly to a Chrome internal page, from within a page of a Chrome Extension
- Select which href ends with some string - Can be used to find href starts with ^=
- Content Scripts
I am new to HTML & jQuery & CSS & Javascript so I apologize for my lack of knowledge in advance. If you are able please explain your answers in detail. If answer is found please comment the functions out so I could manually research them further.
I don't know where to start, what I have so far is what the Getting Started: Building a Chrome Extension has.
----UPDATE .1----
I thank you for your replies and what I've gathered so far from them is this code
<script>
$(document).ready(function(){
$("button").click(function(){
alert($('a').attr('href'));
});
});
</script>
</head>
<body>
<button>Find Href</button>
</body>
but nothing seems to happen. Also instead of alert($('a').attr('href'));
I'm trying to put $('a[href^="magnet"]')
This code is gathered from different websites so I don't know if it is legit (still working) or not.