Javascript/jQuery help
Page 1 of 1
Interinactive
VIP Member



Posts: 29477

PostPosted: Wed, 21st Aug 2013 05:25    Post subject: Javascript/jQuery help
How do you get the CSS value of border-width? Scratch Head

Trying to get a value from:

var defaultThickness = $("#" + $currentPreset).css("border-left-width").replace('px', '');

Always returns 0 when it is 5 Scratch Head

I tried border-width, borderWidth, a million other combinations, I can get every other CSS value but that one
Back to top
Interinactive
VIP Member



Posts: 29477

PostPosted: Wed, 21st Aug 2013 07:34    Post subject:
⁢⁢


Last edited by Interinactive on Tue, 5th Oct 2021 03:06; edited 1 time in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 21st Aug 2013 10:22    Post subject:
Which browser and jQuery version would've been helpful Smile


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Interinactive
VIP Member



Posts: 29477

PostPosted: Wed, 21st Aug 2013 10:28    Post subject:
⁢⁢


Last edited by Interinactive on Tue, 5th Oct 2021 03:06; edited 1 time in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 21st Aug 2013 10:54    Post subject:
Code:
$('#mycoolelement')[0].style.borderWidth
isn't this what you are searching for?

and sans jQuery
Code:
document.getElementByID($currentPreset).style.borderWidth


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Interinactive
VIP Member



Posts: 29477

PostPosted: Wed, 21st Aug 2013 13:35    Post subject:
⁢⁢


Last edited by Interinactive on Tue, 5th Oct 2021 03:06; edited 1 time in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Wed, 21st Aug 2013 14:27    Post subject:
Code:
hey' onclick='alert("what")




=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
shole




Posts: 3363

PostPosted: Wed, 21st Aug 2013 17:24    Post subject:
Interinactive wrote:
.css("border-left-width").replace('px', '');

jquery should always return numbers from css pixel values.. no px parsing or entering should be necessary

however, jquery does not know about css defined outside the dom, so 0 is a valid "none that i know of" answer here
you need to search and manipulate css styles directly or use a library like jss.js
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group