1

I developed a simple js / jQuery only web application that's entirely contained in its own div, meant to go on a Drupal page. The Drupal page only has html in it that loads the jQuery library, loads my javascript file, and sets up the div for the dynamic elements that my code creates to go.

<html>
<head>
<script ...load jquery from google cdn</script>
<script ...load my javascript</script>
</head>
<body>
<div id='my_div'></div>
</body>
</html>

The code executes just fine, except for the lines which change the css. The Drupal theme sets all input divs to a strange color that I'm trying to change. I'm not allowed to change the Drupal theme overall. Calls such as

$("input").css("border", "3px solid red");

don't change anything (all of these calls are also within the .ready() function).

Is there anyone familiar with Drupal and jQuery that can tell me how to override certain Drupal CSS rules on just this page?

4

2 回答 2

0

我猜 Drupal!important用来推翻 jquery 应用的 css。如果使用类应用该 css,那么您可以使用 jqueryremoveClass()删除这些样式。您的示例代码缺少详细信息以查看是否有帮助。

于 2013-03-22T19:49:47.527 回答
0
$("input").css("border", "3px solid red !important");

也许?

更新:显然这是不可能的。 如何使用 .css() 应用 !important?

于 2013-03-22T19:42:07.547 回答