JQuery: removeAttr does not work properly [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I want to remove an attribute of img. Here you can see my codes :
$("#zoom_05").removeAttr('data - zoom - image');
And my img :
<img id="zoom_05" src="http://localhost:3192/ProductImages/Small/093.jpg" data-zoom-image="http://localhost:3192/ProductImages/Larges/093.jpg" />
I can remove src attribute but I can not remove data-zoom-image attribute. Do you have any suggestion?

You are using whitespaces when you shouldn't:
$(document).ready(function(){
$("#zoom_05").removeAttr('data-zoom-image');
});
In case you don't believe me... :) http://jsfiddle.net/7ZTkC/

Related

how to show div using it's ID and change the visibility from none to block? [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 need a javascript code that gets a hidden div by Id and changes the style from display:none; to display:block; .
HTML:
<div id="post-author" style="display:none;">by samuel</div>
every post in my site has that html code on beginning. how can i be able to print or show element by it's Id ? thanks !
<script>document.getElementById("post-author").style.display="block";</script>
This will do what you're after :) Just put that in the head of your site
This has been answered a million times before... but here you go:
document.getElementById('post-author').style.display = 'none';
and
document.getElementById('post-author').style.display = 'block';

Get value using data [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I need get a value using jquery "data()". but I need to do it by doing something like this. So please give me an idea . Thank you in advance.
//html
<div id="myid" data-cityid="Colombo" ></div>
var name = "cityid";
$("#myid").data(""+name+""); // this way not working :(
Your are trying to get attribute, use attr() for it with complete name of attribute:
var name = "data-cityid";
alert($("#myid").attr(name));
Here is demo
You try to use attr():
To get:
$("#myid").attr('data-cityid');
To set:
$("#myid").attr('data-cityid', name);
Try with attr.
$("#myid").attr("data-"+name);

How to read the control id and title inside a span by jquery [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a input text box inside a span . Can anyone help me how to read the input id
<SPAN class=span1><INPUT id=name class="textobx" title=name value=U maxLength=1 ></SPAN>
How will I read the id and title of the input .
Please help me in finding this.
Thanks
Can you try this,
$(function(){
var id = $('span input').attr('id');
var title= $('span input').attr('title');
});
Also, you need to include jquery library
You need to do like this,
var id=$('span input').attr('id');
var tit=$('span input').attr('title');
Which will retrieve the id and title of input tag inside the span.
FIDDLE DEMO

Change background body images with onclick [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm new at javascript and jQuery and I want to use one of those to change my background body images with onclick. Exactly what I want is to create a link with an image so when the people click on it the background body pic will change. Can you help me or give me a simple example.
HTML
<img src="/path/to/image.jpg">Select Image
Javascript
$(document).on('click', 'a.set-background', function(){
$('body').css({
'background' : 'url(' + $(this).find('img').attr('src') + ')'
});
return false;
});
HTML:
<button>Change background</button>
jQuery:
$('button').click(function(){
$('body').css('background-image','image.jpg');
});

Unhiding Row using jQuery toggle [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
http://jsfiddle.net/PF8nL/1/
Using the code in the above jsfiddle I am unable to unhide and hide a row using jQuery. According to this stack answer it seems I am doing this correctly.
Do I have some stupid error? possibly causing this?
Code:
$('input[name="custom_rejection_option"]').click(function() {
$('.custom_reject_area').toggle(this.checked);
}};
You had a syntax error
$('input[name="custom_rejection_option"]').click(function () {
$('.custom_reject_area').toggle(this.checked);
});
//You had `}` instead of the closing `)`
You just had some typos and things.
$('input[name=custom_rejection_option]').click(function() {
$('.custom_reject_area').toggle(this.checked);
});
http://jsfiddle.net/PF8nL/5/

Categories

Resources