2014-03-26 22 views
0

我有一個MVC4 Razor應用程序,我需要在包含@class的javascript部分中構造一個字符串。我怎樣才能逃避在字符串中使用它?如何在帶有MVC4的字符串中使用@class

var S = 'select * from html where url=\"www.yahoo.com\" and xpath=\'\//div[contains('@class,\"techSpecsTable/\")]\' ' 

我該如何逃避@class?

+0

你不需要逃避'@ class',你需要什麼「@ class」之前的轉義就是你的撇號。 –

回答

2

您可以通過執行

@@class 

逃脫@class,但我認爲你需要excape的「

var S = 'select * from html where url=\"www.yahoo.com\" and xpath=\'\//div[contains(\'@class,\"techSpecsTable/\")]\' ' 
+0

@@ class非常感謝! – user1813251

相關問題