Call function inside href using Jquery [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
i have this link
Test
Now when i click directly on the link .. The alert get popped up in my window.
But, $("#myLink").click();
doesn't call the popup.
EDIT : I need to trigger the function inside href using jQuery
Solved --------- :
var x = $('#myLink').attr("href");
window.location = x;

Figured out..
var x = $('#myLink').attr("href");
window.location = x;
getting the href value and then targeting it .. solved the problem.

Try href="javascript:alert ('test')" or onclick="alert ('test')"

Related

Where to put Error Alert in my JS [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Where I need to place Error Alert code in this JavaScript and if it is of any use in such JavaScript.
<script>
$(document).ready(function () {
$.get("ImagePreview?b_id=<%=id%>", function (responseJson) {
var $select = $("<div>").addClass("galleria").appendTo($("#imgas"));
$.each(responseJson, function (index, item) {
$("<img />").attr("src", item).appendTo($select);
});
});
});
</script>
Put an alert every odd line like alert("A"), alert("B") etc
Refresh the page
Remove every alert from your code and keep the one you like best
P.S: if you want to test the actual responseJson than alert is a bad idea.
Use console.dir(responseJson); inside your AJAX function.

Output div id data into javascript variable [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Got this div id with html data, how can i output that html data into a javascript variable? example
var url = '(HtmlDivId)'; is this possible?
Are you are trying to read content of the div?
//jQuery
var url = $('#HtmlDivId').html();
//javascript
var url = document.getElementById('HtmlDivId').innerHTML;
Sure
var url = document.getElementById('html-div-id').innerHTML;

How do I make every TR tag in a table a link with Perl and Javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
If I have a tag called "post" and has href="something from perl" what should i use for javascript in order to make it clickable and redirects me to the link?
If you implement jQuery you can do something like this:
jQuery(document).ready(function($) {
$(".click").click(function() {
window.document.location = $(this).attr("href");
});
});
edit
assuming your tag looks like this
<tr class = "click" href = "<%= something from Perl %>">

How to trigger a JavaScript function after “Bootstrap: collapse plugin” transition is done [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I use this method
$jq('#indexClassData').on('hidden', function () {
// Do something…
expandIndexClass();
})
It does not work. What am I missing?
You need to wait for the "hidden.bs.collapse" event, not "hidden".
Scroll down to "Events" here: http://getbootstrap.com/javascript/#collapse-usage
thank you but i use another method
// ahmed taha to fix issue of documet coolapse
$jq('#indexClassData').on('shown.bs.collapse', function () {
expandIndexClass()
})

Contents between tags to turn into title JS [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have <a class="wishlist">TEXT</a>
i need <a class="wishlist" title="TEXT"></a>
I can use only JS.
As your selector is a class, I'd set the function up to handle the possibility of multiples.
$('.wishlist').each(function() {
$(this).attr( 'title', $(this).text() ).empty();
});
Don't forget to either place this code after your HTML, or wrap it in document.ready.
$('.wishlist').attr('title', $('.wishlist').text() );
$(".wishlist").attr("title", $(".wishlist").text()).text("");
That will set the title attribute to the current text, and afterwards unset the text.
try it again:
$('.wishlist').attr('attr','TEXT').html("");
document.getElementsByClassName('wishlist').title = 'TEXT'
document.getElementsByClassName('wishlist').innerHTML = ''

Categories

Resources