jQuery的:元素文本的分裂和变色 [英] jquery: split and change color of element text

查看:119
本文介绍了jQuery的:元素文本的分裂和变色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net mvc的项目。
 我已经加入SQL_ERROR属性,我的模型。当所有的输入值rihth它是将其写入到数据库。是否会有一些插入到数据库时的错误,它会返回错误作为的ErrorMessage:WhatYouMustDo。而我加入此错误的ModelState。它会在验证,汇总错误自动showen DIV通过MVC生成的。

my project in asp.net mvc. I have added SQL_Error property to my model. When all input value is rihth it is going to write it to DB. if there will some error when inserting to DB, it will return Error as ErrorMessage : WhatYouMustDo . and i am adding this error to modelState. and it will automatically showen in validation-summary-errors div generated by mvc.

它会显示如下:< UL><李>的ErrorMessage:WhatYouMustDo< /李>< / UL>

现在我想改变后,李文字()的颜色:使用jQuery字符

and now i want to change color of li text() after ':' char with jquery

结果:结果
的ErrorMessage:(颜色 - >红)结果
WhatYouMustDo:(颜色 - >蓝色)搜索

我想这样做的最好的办法。

i want best way to do it

推荐答案

请看看这个

Please Look at this this

$(document).ready(function()
              {

                  var str = $('li').text();
                  var substr = str.split(':');
                  var myhtml="<span style='color:red;'>"+substr[0]+"</span>:<span style='color:blue;'>"+substr[1]+"</span>";

                  $('li').html(myhtml);



              });

这篇关于jQuery的:元素文本的分裂和变色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆