jarvis Posted August 19, 2020 Share Posted August 19, 2020 HI All, I'm hoping someone can help! I need to either remove or change a DIV tag directly above another. Here's the code: <div style="clear:both;"></div> <div class="berocket_lgv_widget" style="float:left;padding: 5px 0px 5px 0px;"> Either the entire first DIV needs removing or change the style to clear:none I thought something like: $(".berocket_lgv_widget").prev().attr("style", " clear:none"); $(".berocket_lgv_widget").prev().remove(); No joy with either. I also tried before() Any help is much appreciated Thanks Quote Link to comment https://forums.phpfreaks.com/topic/311346-remove-or-edit-div-with-jquery/ Share on other sites More sharing options...
requinix Posted August 19, 2020 Share Posted August 19, 2020 Manipulating appearance like this is a pain. You know what's easier? Applying a class to an appropriate container ancestor and using CSS rules. Quote Link to comment https://forums.phpfreaks.com/topic/311346-remove-or-edit-div-with-jquery/#findComment-1580757 Share on other sites More sharing options...
jarvis Posted August 20, 2020 Author Share Posted August 20, 2020 Thanks @requinix Unfortunately, this stems from a Wordpress build and the code is generated by a plugin, so its beyond my control. Quote Link to comment https://forums.phpfreaks.com/topic/311346-remove-or-edit-div-with-jquery/#findComment-1580783 Share on other sites More sharing options...
requinix Posted August 20, 2020 Share Posted August 20, 2020 I don't think you understand me. You can write the Javascript, yes? I sure hope so because that's a rather important aspect to the problem you're describing. I'm not saying you don't write Javascript. I'm saying you don't write Javascript that tries to manipulate the element's style. I'm saying you do write Javascript that adds/removes CSS classes from some appropriate ancestor element, then handle the appearance changes with a CSS rule. Quote Link to comment https://forums.phpfreaks.com/topic/311346-remove-or-edit-div-with-jquery/#findComment-1580784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.