Suppose We have
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Its output will be "dgdfgffgf"
But What if i want all <a> tags used will have output like its text + href attribute
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Like this - "dgdfgffgf (https://solvecode.blogspot.in)"
So for this we can create very simple plugin that can do it easily by using each loop.
Here is the code :
<script src="Scripts/jquery-2.1.1.js"></script>
<script src="Scripts/jquery-ui.js"></script>
<script type="text/javascript">
$.fn.showlinklocation = function () {
this.filter("a").each(function () {
var link = $(this);
link.append(" (" + link.attr("href") + ") ");
});
return this;
};
$(document).ready(function () {
$("a").showlinklocation();
});
</script>
Suppose we have
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Then its output will be like
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
Done :)
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Its output will be "dgdfgffgf"
But What if i want all <a> tags used will have output like its text + href attribute
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Like this - "dgdfgffgf (https://solvecode.blogspot.in)"
So for this we can create very simple plugin that can do it easily by using each loop.
Here is the code :
<script src="Scripts/jquery-2.1.1.js"></script>
<script src="Scripts/jquery-ui.js"></script>
<script type="text/javascript">
$.fn.showlinklocation = function () {
this.filter("a").each(function () {
var link = $(this);
link.append(" (" + link.attr("href") + ") ");
});
return this;
};
$(document).ready(function () {
$("a").showlinklocation();
});
</script>
Suppose we have
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
<a href="https://solvecode.blogspot.in">dgdfgffgf</a><br />
Then its output will be like
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
dgdfgffgf (https://solvecode.blogspot.in)
Done :)
Comments
Post a Comment