简体   繁体   English

如何在Rails应用程序的Java脚本中格式化文本

[英]how to format text in java script in rails apps

I have a with id this is logic so here i am sending text dynamically now i want to resize and recolour this text. 我有一个ID,这是逻辑,所以在这里,我现在要动态发送文本,我想调整此文本的大小和颜色。 my jquery look like this 我的jQuery看起来像这样

<script type="text/javascript">
 $(function($){
 $("#daily_type").change(function()
{
  logic = $(this).val()

  LogicShow(logic)
})
function LogicShow(logic)
{

  if ( logic == "iss" )
  {
    var spanText = "Based on the severity High" ;
    $("#logic_change").html(spanText);
  }
  if ( logic == "unix" )
  {
    var spanText = "Summary reflects based on the number of events.Such as how many times number of events observed" ;
    $("#logic_change").html(spanText);
  }

}
});

</script>

so now how can i pass text with some good text format and colour. 所以现在我该如何传递具有良好文本格式和颜色的文本。

Giving a class with a span wrapping. classspan教学。

var spanText = '<span class="logictext">Based on the severity High</span>' ;

And then wrote css for those class es. 然后为这些class es编写CSS。

Or you can give inline css as well: 或者,您也可以提供内联CSS:

var spanText = '<span style="color: #f00;">Based on the severity High</span>' ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM